package cn.itlaobing.service.impl;

import cn.itlaobing.dao.UserDao;
import cn.itlaobing.model.UserModel;
import cn.itlaobing.service.UserService;

import java.sql.SQLException;

/**
 * Created by xuaner on 2017/11/6.
 */
public class UserServiceImpl implements UserService {
    @Override
    public UserModel authentication(String user_name,String user_pwd){
        UserDao userDao=new UserDao();
        try {
            UserModel um=userDao.findByUserName(user_name);
            //System.out.println(um);
            if(um==null){
              //  System.out.println(um);
                return  um;

            }
            if(!um.getUser_pwd().equals(user_pwd)){
                return null;
            }

            //登录成功
            userDao.updateTime(um.getUser_id());
            return um;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
